package com.gc.baselib.base.event;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.gc.baselib.base.NavManager;

import org.jetbrains.annotations.Nullable;

/**
 * @author admin
 * @Date 2022/6/11 16:02
 * @package： com.zk.baselib.base.event
 * @decrpition
 */
public class NavigationEvent {
    public static final int Nav_Type_Activity=1;
    public static final int Nav_Type_Fragment=2;
    private boolean isCloseSelf;
    private Class<?> clazz;

    public String getPath() {
        return path;
    }

    public NavigationEvent setPath(String path) {
        this.path = path;
        return this;
    }

    private String path;
    private Bundle bundle;
    private int reqCode=-1;//
    private int navType=Nav_Type_Activity;

    public boolean isClearAll() {
        return isClearAll;
    }

    public NavigationEvent setClearAll(boolean clearAll) {
        isClearAll = clearAll;
        return this;
    }

    private boolean isClearAll;



    private int navId;
    public NavigationEvent(){}
    public NavigationEvent(Class<?> clazz) {
        this.clazz = clazz;
    }
    public NavigationEvent(int navId) {
        this.navId = navId;
    }

    public NavigationEvent(Class<?> clazz, Bundle bundle) {
        this.clazz = clazz;
        this.bundle = bundle;
    }
    public NavigationEvent(String path) {
        this.path = path;
    }
    public NavigationEvent(String path, Bundle bundle) {
        this.path = path;
        this.bundle = bundle;
    }
    public NavigationEvent(String path, Bundle bundle, int reqCode) {
        this.path = path;
        this.bundle = bundle;
        this.reqCode = reqCode;
    }

    public NavigationEvent(Class<?> clazz, Bundle bundle, int reqCode) {
        this.clazz = clazz;
        this.bundle = bundle;
        this.reqCode = reqCode;
    }

    public boolean isCloseSelf() {
        return isCloseSelf;
    }

    public NavigationEvent setCloseSelf(boolean closeSelf) {
        isCloseSelf = closeSelf;
        return this;
    }

    public Class<?> getClazz() {
        if(clazz==null&&path!=null){
            return NavManager.INSTANCE.getNavPath(path);
        }
        return clazz;
    }

    public NavigationEvent setClazz(Class<?> clazz) {
        this.clazz = clazz;
        return this;
    }

    public Bundle getBundle() {
        return bundle;
    }

    public NavigationEvent setBundle(Bundle bundle) {
        this.bundle = bundle;
        return this;
    }

    public int getReqCode() {
        return reqCode;
    }

    public NavigationEvent setReqCode(int reqCode) {
        this.reqCode = reqCode;
        return this;
    }

    public int getNavType() {
        return navType;
    }

    public NavigationEvent setNavType(int navType) {
        this.navType = navType;
        return this;
    }
    public int getNavId() {
        return navId;
    }

    public void setNavId(int navId) {
        this.navId = navId;
    }

    @Nullable
    public Intent getIntent(Context context) {
        Intent intent = new Intent();
        intent.setClass(context,getClazz());
        return intent;
    }
}
